package com.lnking.lnkingplace.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lnking.lnkingplace.mapper.NucleicAcidSetMapper;
import com.lnking.lnkingplace.model.entity.NucleicAcidSet;
import com.lnking.lnkingplace.model.enums.NucleicAcidSetType;
import com.lnking.lnkingplace.service.INucleicAcidSetService;
import com.lnking.starter.mybatis.service.impl.CustomServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 核酸检测设置时间选择 服务实现类
 * </p>
 *
 * @author sn
 * @since 2022-08-23
 */
@Service
public class NucleicAcidSetServiceImpl extends CustomServiceImpl<NucleicAcidSetMapper, NucleicAcidSet> implements INucleicAcidSetService {

    @Override
    public NucleicAcidSet find(String userId) {
        QueryWrapper<NucleicAcidSet> Swapper=new QueryWrapper<>();
        Swapper.lambda().eq(NucleicAcidSet::getUserId,userId);
        NucleicAcidSet nucleicAcidSet = getBaseMapper().selectOne(Swapper);
        // 如果当前监督人员没有设置
        if(null == nucleicAcidSet){
            nucleicAcidSet=new NucleicAcidSet();
            nucleicAcidSet.setUserId(userId);
            nucleicAcidSet.setType(NucleicAcidSetType.THREE.getCode());
            getBaseMapper().insert(nucleicAcidSet);
        }
        return nucleicAcidSet;
    }
}
